
# string 和 byte 转换

ms = "我是中文"

print(ms)

print(ms.encode(encoding = "utf-8"))
print(ms.encode(encoding = "utf-8").decode(encoding = "utf-8"))


# 列表

names = ["zhang","liu","wen","gun","wen"]
names.append("wen")
names.insert(3,"da")
names[2] = "xiedi"

# delete
# names.remove("da")
# del names[0]  # = names.pop(0)


print(names)
    # 切片
# print(names[0])
# print(names[1:3])
# print(names[-1])

# 查找索引
# print(names.index("da"))

# 查找同名个数
# print(names.count("wen"))

# 反转
# names.reverse()
# print(names)

# 排序
# names.sort()
# print(names)

# names2 = [1,2,3,4]

# names.extend(names2)
# # del names2
# print(names,names2)

# 浅拷贝
names3 = [0,9,8,["a","b","c"],5,3,6,7]
# names4 = names3.copy()
# n1 = copy.copy(names3)    浅拷贝的3种方式
# n2 = names3[:]
# n3 = list(names3)
# print(names3)
names3[3][0] = 90
# print(names4)

# 深拷贝 需要导入模块

# import copy

# names4 = copy.deepcopy(names3)  # 模块浅拷贝copy.copy(names3)
# print(names3)
# print(names4)

# for循环取值
# for i in names3:
#     print(i)

print(names3)
print(names3[0:-1:2])
print(names3[::2])      # 简写